/**
 * 配置浏览器本地存储的方式，可直接存储对象数组。
 */

import WebStorageCache from 'web-storage-cache'

type CacheType = 'sessionStorage' | 'localStorage'

export const useCache = (type: CacheType = 'sessionStorage') => {
  const wsCache: WebStorageCache = new WebStorageCache({
    storage: type
  })

  return {
    wsCache
  }
}

export const CACHE_KEY = {
  IS_DARK_CACHE: 'isDarkCache',
  USER_CACHE: 'userCache',
  LANG_CACHE: 'langCache',
  THEME_CACHE: 'themeCache',
  LAYOUT_CACHE: 'layoutCache',
  ROLE_ROUTERS_CACHE: 'roleRoutersCache',
  DICT_CACHE: 'dictCache'
}
